package com.atguigu.sugar.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface ProductMapper {
    // 计算 指定日期的总的交易额
    // 2021-12-12 20211212
    @Select("select " +
            "sum(order_amount) order_amount " +
            "from product_stats_2021 " +
            "where toYYYYMMDD(stt)=#{date}; ")
    BigDecimal gmv(@Param("date") int date);

    @Select("select category3_name, " +
            "sum(order_amount) order_amount " +
            "from product_stats_2021 " +
            "where toYYYYMMDD(stt)=#{date} " +
            "group by category3_name;")
    List<Map<String,Object>> gmvByC3(@Param("date") int date);
    @Select(" select spu_name, " +
            "sum(order_amount) order_amount " +
            "from product_stats_2021 " +
            "where toYYYYMMDD(stt)=#{date} " +
            "group by spu_name;")
    BigDecimal gmvspu(@Param("date") int date);

}
